package com.taiyuan.zfmvp.shejimoshi.single.type6;

/**
 * @param 
 * @Author: zhoufang@si-tech.com.cn
 * @Descriiption:  静态内部类 单例
 * @Date 2022/10/3
 * @return
 */
public class SingletonTest06 {
    public static void main(String[] args) {
        Singelton singelton = Singelton.getInstance();
        Singelton singelton2 = Singelton.getInstance();
        System.out.println(singelton == singelton2);
    }
}

class  Singelton{


    private Singelton(){

    }

    //写一个静态内部类 该类中有一个静态属性 Singleton
    private static class SingletonInstace{
        private  static   final  Singelton INSTANCE = new Singelton();
    }

    //提供一个静态共有方法 直接返回
    public static Singelton getInstance(){
        return  SingletonInstace.INSTANCE;
    }

}
